﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CSP.Receipts.Business;
using MySharpReceipts.Models;
using Ninject;

namespace MySharpReceipts.Controllers
{
    public class HomeController : BaseController
    {
        private readonly IReceiptRepository repository;

        public HomeController(IReceiptRepository repos)
        {
            this.repository = repos;
        }

        public ActionResult Index()
        {
            HomeIndexModel model = new HomeIndexModel();
            model.NewReceipts = repository.GetNewReceipts();
            model.Tags = Kernel.Get<ICategoryRepository>().GetReceiptsCountByCategory();
            model.CountAllReceipts = repository.GetAll().Count();
            if (User.Identity.IsAuthenticated)
                model.CountMyReceipts = repository.GetReceiptsByUser(CurrentUser.Id).Count();
            return View(model);
        }

        public ActionResult About()
        {
            return View();
        }        
    }
}
